<!DOCTYPE HTML>
<html lang="zh-CN">

<head>
    <!--Setting-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta http-equiv="Cache-Control" content="no-transform">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="apple-mobile-web-app-capable" content="涛哥的博客">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no,adress=no">
    <meta name="browsermode" content="application">
    <meta name="screen-orientation" content="portrait">
    <meta name="theme-version" content="1.2.3">
    <meta name="root" content="/">
    <link rel="dns-prefetch" href="https://jaredtao.github.io">
    <!--SEO-->

<meta name="keywords" content="Qt,彩色log" />


<meta name="description" content="简介我们在Qt Creator中开发程序的时候，经常要做的一件事情，就是看程序的输出Log。一般的log信息都是黑白的，比如这样的：
涛哥在这里告诉大家一个隐藏的技能，那就是输出彩色的log:
..." />


<meta name="robots" content="all" />
<meta name="google" content="all" />
<meta name="googlebot" content="all" />
<meta name="verify" content="all" />
    <!--Title-->

<title>
    
    玩转Qt(1)-输出彩色log |
    
    涛哥的博客
</title>

<link rel="alternate" href="/atom.xml" title="涛哥的博客" type="application/atom+xml">


<link rel="icon" href="/favicon.ico">

    


<link rel="stylesheet" href="/css/bootstrap.min.css?rev=3.3.7.css">
<link rel="stylesheet" href="/css/font-awesome.min.css?rev=4.7.0.css">
<link rel="stylesheet" href="/css/style.css?rev=@@hash.css">

    
<div class="hide">
    <script type="text/javascript">
    var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");
    document.write(unescape("%3Cspan class='cnzz_stat_icon_1263868967 hide' %3E%3Cscript%20src%3D%22https%3A%2F%2Fs95.cnzz.com%2Fz_stat.php%3Fweb_id%3D1272564536%22%3E%3C%2Fscript%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s19.cnzz.com/z_stat.php%3Fid%3D1263868967%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));
    </script>
</div>




    

<script>
(function() {
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    } else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>

<meta name="generator" content="Hexo 4.2.1"></head>
<!--[if lte IE 8]>
<style>
    html{ font-size: 1em }
</style>
<![endif]-->
<!--[if lte IE 9]>
<div style="ie">你使用的浏览器版本过低，为了你更好的阅读体验，请更新浏览器的版本或者使用其他现代浏览器，比如Chrome、Firefox、Safari等。</div>
<![endif]-->
<body>
    <header class="main-header"  style="background-image:url(
    http://snippet.shenliyang.com/img/banner.jpg)"
     >
    <div class="main-header-box">
        <a class="header-avatar" href="/" title='JaredTao'>
            <img src="/img/avatar.jpg" alt="logo头像" class="img-responsive center-block">
        </a>
        <div class="branding">
            <!--<h2 class="text-hide">Snippet主题,从未如此简单有趣</h2>-->
            
            <h2>
                单枪匹马亦对饮，历经磨难记初心
            </h2>
            
        </div>
    </div>
</header>
    <nav class="main-navigation">
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <div class="navbar-header"><span class="nav-toggle-button collapsed pull-right" data-toggle="collapse" data-target="#main-menu" id="mnav">
                        <span class="sr-only"></span>
                        <i class="fa fa-bars"></i>
                    </span>
                    <a class="navbar-brand" href="https://jaredtao.github.io">
                        涛哥的博客</a>
                </div>
                <div class="collapse navbar-collapse" id="main-menu">
                    <ul class="menu">
                        
                        <li role="presentation" class="text-center">
                            <a href="/"><i class="fa "></i>
                                首页</a>
                        </li>
                        
                        <li role="presentation" class="text-center">
                            <a href="/categories/玩转Qt/"><i class="fa "></i>
                                玩转Qt</a>
                        </li>
                        
                        <li role="presentation" class="text-center">
                            <a href="/categories/玩转Qml/"><i class="fa "></i>
                                玩转Qml</a>
                        </li>
                        
                        <li role="presentation" class="text-center">
                            <a href="/categories/玩转QtQuick/"><i class="fa "></i>
                                玩转QtQuick</a>
                        </li>
                        
                        <li role="presentation" class="text-center">
                            <a href="/categories/涛哥的博客/"><i class="fa "></i>
                                涛哥的博客</a>
                        </li>
                        
                        <li role="presentation" class="text-center">
                            <a href="/archives/"><i class="fa "></i>
                                时间轴</a>
                        </li>
                        
                    </ul>
                </div>
            </div>
        </div>
    </div>
</nav>
    <section class="content-wrap">
        <div class="container">
            <div class="row">
                <main class="col-md-8 main-content m-post">
                    <p id="process"></p>
<article class="post">
    <div class="post-head">
        <h1 id="玩转Qt(1)-输出彩色log">
            
            玩转Qt(1)-输出彩色log
            
        </h1>
        <div class="post-meta">
    
    <span class="categories-meta fa-wrap">
        <i class="fa fa-folder-open-o"></i>
        <a class="category-link" href="/categories/%E7%8E%A9%E8%BD%ACQt/">玩转Qt</a>
    </span>
    
    
    <span class="fa-wrap">
        <i class="fa fa-tags"></i>
        <span class="tags-meta">
            
            <a class="tag-link" href="/tags/Qt/" rel="tag">Qt</a> <a class="tag-link" href="/tags/%E5%BD%A9%E8%89%B2log/" rel="tag">彩色log</a>
            
        </span>
    </span>
    
    
    
    <span class="fa-wrap">
        <i class="fa fa-clock-o"></i>
        <span class="date-meta">
            2019/04/29</span>
    </span>
    
    <span class="fa-wrap">
        <i class="fa fa-eye"></i>
        <span id="busuanzi_value_page_pv"></span>
    </span>
    
    
</div>
        
        
        <p class="fa fa-exclamation-triangle warning">
            本文于<strong>
                708</strong>
            天之前发表，文中内容可能已经过时。
        </p>
        
    </div>
    
<div id="post-gallery">
    
    <img src="/images/ConsoleColor/Image1.png" alt="gallery-img" class="gallery">
    
</div>

    <div class="post-body post-content">
        <h2 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h2><p>我们在Qt Creator中开发程序的时候，经常要做的一件事情，就是看程序的输出Log。<br>一般的log信息都是黑白的，比如这样的：<br><img src="/images/ConsoleColor/Image1.png" alt="fa4bb028a52e28887c9ec2a3c8b192dc.png"></p>
<p>涛哥在这里告诉大家一个隐藏的技能，那就是输出彩色的log:</p>
<p><img src="/images/ConsoleColor/2.jpg" alt="293105e6f37901923d3576fcd12c650f.png"></p>
<p>从此看到的log，不再是黑白的，而是五颜六色的，生活更加绚丽多彩。</p>
<h2 id="原理"><a href="#原理" class="headerlink" title="原理"></a>原理</h2><p>要输出彩色信息有点类似于html的语法，即在要输出的文字前加上转义字符。<br>指令格式如下\033[<em>m<br>这里的</em>就是转义字符，例如我们要输出一段绿色的文字,则<br>qDebug() &lt;&lt; “\033[32m” &lt;&lt;”Hello!”;<br>即在输出文字前，先输出一个颜色指令。<br>注意这个指令对后续的输出都会生效，如果想关掉颜色只要再输出0号指令即可<br>qDebug() &lt;&lt; “\033[0m”;</p>
<p>这里有一个指令表</p>
<figure class="highlight angelscript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">　　<span class="number">0</span> : Reset Color Attributes</span><br><span class="line">　　<span class="number">1</span> : 加粗</span><br><span class="line">　　<span class="number">2</span> : 去粗</span><br><span class="line">　　<span class="number">4</span> : 下划线</span><br><span class="line">　　<span class="number">5</span> : 闪烁</span><br><span class="line">　　<span class="number">7</span> : 反色</span><br><span class="line">　　<span class="number">21</span>/<span class="number">22</span> : 加粗 正常</span><br><span class="line">　　<span class="number">24</span> : 去掉下划线</span><br><span class="line">　　<span class="number">25</span> : 停止闪烁</span><br><span class="line">　　<span class="number">27</span> : 反色</span><br><span class="line">　　<span class="number">30</span> : 前景，黑色</span><br><span class="line">　　<span class="number">31</span> : 前景，红色</span><br><span class="line">　　<span class="number">32</span> : 前景，绿色</span><br><span class="line">　　<span class="number">33</span> : 前景，黄色</span><br><span class="line">　　<span class="number">34</span> : 前景，篮色</span><br><span class="line">　　<span class="number">35</span> : 前景，紫色</span><br><span class="line">　　<span class="number">36</span> : 前景，青色</span><br><span class="line">　　<span class="number">37</span> : 前景，白色</span><br><span class="line">　　<span class="number">40</span> : 背景，黑色</span><br><span class="line">　　<span class="number">41</span> : 背景，红色</span><br><span class="line">　　<span class="number">42</span> : 背景，绿色</span><br><span class="line">　　<span class="number">43</span> : 背景，黄色</span><br><span class="line">　　<span class="number">44</span> : 背景，篮色</span><br><span class="line">　　<span class="number">45</span> : 背景，紫色</span><br><span class="line">　　<span class="number">46</span> : 背景，青色</span><br><span class="line">　　<span class="number">47</span> : 背景，白色</span><br><span class="line">其它转义字符命令</span><br><span class="line">    清除屏幕 : /<span class="number">033</span>c</span><br><span class="line">　　设定水平标位置 : /<span class="number">033</span>[XG</span><br><span class="line">　　X为水平标位置。</span><br><span class="line">　　设定垂直标位置 : /<span class="number">033</span>[Xd</span><br><span class="line">　　Y为垂直标位置。</span><br><span class="line">    /<span class="number">033</span>[<span class="number">0</span>K : 删除从标到该行结尾</span><br><span class="line">　　/<span class="number">033</span>[<span class="number">1</span>K : 删除从该行开始到标处</span><br><span class="line">　　/<span class="number">033</span>[<span class="number">2</span>K : 删除整行　</span><br><span class="line">　　/<span class="number">033</span>[<span class="number">0</span>J : 删除标到萤幕结尾</span><br><span class="line">　　/<span class="number">033</span>[<span class="number">1</span>J : 删除从萤幕开始到标处</span><br><span class="line">　　/<span class="number">033</span>[<span class="number">2</span>J : 删除整个屏幕</span><br></pre></td></tr></table></figure>
<p>涛哥在QtCreator中测试了，只有颜色和加粗指令能生效。</p>
<h2 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h2><p>（代码使用C++11标准）</p>
<p>为了方便、直观地使用，涛哥定义了一套枚举</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">enum</span> <span class="class"><span class="keyword">class</span> <span class="title">LogType</span> &#123;</span></span><br><span class="line">    Reset = <span class="number">0</span>,</span><br><span class="line"></span><br><span class="line">    Bold,</span><br><span class="line">    Unbold,</span><br><span class="line"></span><br><span class="line">    FrontBlack,</span><br><span class="line">    FrontRed,</span><br><span class="line">    FrontGreen,</span><br><span class="line">    FrontYellow,</span><br><span class="line">    FrontBlue,</span><br><span class="line">    FrontPurple,</span><br><span class="line">    FrontCyan,</span><br><span class="line">    FrontWhite,</span><br><span class="line">    BackBlack,</span><br><span class="line">    BackRed,</span><br><span class="line">    BackGreen,</span><br><span class="line">    BackYellow,</span><br><span class="line">    BackBlue,</span><br><span class="line">    BackPurple,</span><br><span class="line">    BackCyan,</span><br><span class="line">    BackWhite,</span><br><span class="line"></span><br><span class="line">    TypeCount</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<p>之后又写了一个指令列表，顺序和前面的枚举一一对应</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">char</span> * logCommands[] = &#123;</span><br><span class="line">    <span class="string">"\033[0m"</span>,</span><br><span class="line">    <span class="string">"\033[1m"</span>,</span><br><span class="line">    <span class="string">"\033[2m"</span>,</span><br><span class="line">    <span class="string">"\033[30m"</span>,</span><br><span class="line">    <span class="string">"\033[31m"</span>,</span><br><span class="line">    <span class="string">"\033[32m"</span>,</span><br><span class="line">    <span class="string">"\033[33m"</span>,</span><br><span class="line">    <span class="string">"\033[34m"</span>,</span><br><span class="line">    <span class="string">"\033[35m"</span>,</span><br><span class="line">    <span class="string">"\033[36m"</span>,</span><br><span class="line">    <span class="string">"\033[37m"</span>,</span><br><span class="line">    <span class="string">"\033[40m"</span>,</span><br><span class="line">    <span class="string">"\033[41m"</span>,</span><br><span class="line">    <span class="string">"\033[42m"</span>,</span><br><span class="line">    <span class="string">"\033[43m"</span>,</span><br><span class="line">    <span class="string">"\033[44m"</span>,</span><br><span class="line">    <span class="string">"\033[45m"</span>,</span><br><span class="line">    <span class="string">"\033[46m"</span>,</span><br><span class="line">    <span class="string">"\033[47m"</span>,</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<p>这样就可以通过查表的方式，拿到对应的颜色指令了</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">logCommands[(<span class="keyword">int</span>)(LogType::FrontYellow)]</span><br></pre></td></tr></table></figure>
<p>这个代码使用了c的强制转换，在c++11标准中会报警告，建议用static_cast。<br>所以涛哥又写了一个转换函数,将枚举通过static_cast转换成int类型。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> EnumType, <span class="keyword">typename</span> IntType = <span class="keyword">int</span>&gt;</span><br><span class="line"><span class="keyword">int</span> enumToInt(EnumType enumValue)</span><br><span class="line">&#123;</span><br><span class="line">    <span class="keyword">static_assert</span> (<span class="built_in">std</span>::is_enum&lt;EnumType&gt;::value, <span class="string">"EnumType must be enum"</span>);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">static_cast</span>&lt;IntType&gt;(enumValue);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


<p>最后就是代码的全貌了</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;QDebug&gt;</span></span></span><br><span class="line"><span class="keyword">enum</span> <span class="class"><span class="keyword">class</span> <span class="title">LogType</span> &#123;</span></span><br><span class="line">    Reset = <span class="number">0</span>,</span><br><span class="line"></span><br><span class="line">    Bold,</span><br><span class="line">    Unbold,</span><br><span class="line"></span><br><span class="line">    FrontBlack,</span><br><span class="line">    FrontRed,</span><br><span class="line">    FrontGreen,</span><br><span class="line">    FrontYellow,</span><br><span class="line">    FrontBlue,</span><br><span class="line">    FrontPurple,</span><br><span class="line">    FrontCyan,</span><br><span class="line">    FrontWhite,</span><br><span class="line">    BackBlack,</span><br><span class="line">    BackRed,</span><br><span class="line">    BackGreen,</span><br><span class="line">    BackYellow,</span><br><span class="line">    BackBlue,</span><br><span class="line">    BackPurple,</span><br><span class="line">    BackCyan,</span><br><span class="line">    BackWhite,</span><br><span class="line"></span><br><span class="line">    TypeCount</span><br><span class="line">&#125;;</span><br><span class="line"><span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">char</span> * logCommands[] = &#123;</span><br><span class="line">    <span class="string">"\033[0m"</span>,</span><br><span class="line">    <span class="string">"\033[1m"</span>,</span><br><span class="line">    <span class="string">"\033[2m"</span>,</span><br><span class="line">    <span class="string">"\033[30m"</span>,</span><br><span class="line">    <span class="string">"\033[31m"</span>,</span><br><span class="line">    <span class="string">"\033[32m"</span>,</span><br><span class="line">    <span class="string">"\033[33m"</span>,</span><br><span class="line">    <span class="string">"\033[34m"</span>,</span><br><span class="line">    <span class="string">"\033[35m"</span>,</span><br><span class="line">    <span class="string">"\033[36m"</span>,</span><br><span class="line">    <span class="string">"\033[37m"</span>,</span><br><span class="line">    <span class="string">"\033[40m"</span>,</span><br><span class="line">    <span class="string">"\033[41m"</span>,</span><br><span class="line">    <span class="string">"\033[42m"</span>,</span><br><span class="line">    <span class="string">"\033[43m"</span>,</span><br><span class="line">    <span class="string">"\033[44m"</span>,</span><br><span class="line">    <span class="string">"\033[45m"</span>,</span><br><span class="line">    <span class="string">"\033[46m"</span>,</span><br><span class="line">    <span class="string">"\033[47m"</span>,</span><br><span class="line">&#125;;</span><br><span class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> EnumType, <span class="keyword">typename</span> IntType = <span class="keyword">int</span>&gt;</span><br><span class="line"><span class="keyword">int</span> enumToInt(EnumType enumValue)</span><br><span class="line">&#123;</span><br><span class="line">    <span class="keyword">static_assert</span> (<span class="built_in">std</span>::is_enum&lt;EnumType&gt;::value, <span class="string">"EnumType must be enum"</span>);</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="keyword">static_cast</span>&lt;IntType&gt;(enumValue);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">int</span> argc, <span class="keyword">char</span> *argv[])</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = enumToInt(LogType::Bold); i &lt; enumToInt(LogType::TypeCount); ++i)</span><br><span class="line">    &#123;</span><br><span class="line">        qInfo().nospace() &lt;&lt; logCommands[i] &lt;&lt; i &lt;&lt; <span class="string">" Hello World"</span> &lt;&lt; logCommands[<span class="number">0</span>];</span><br><span class="line">    &#125;</span><br><span class="line">    qWarning() &lt;&lt; logCommands[enumToInt(LogType::FrontBlue)]</span><br><span class="line">               &lt;&lt; logCommands[enumToInt(LogType::BackRed)]</span><br><span class="line">               &lt;&lt; <span class="string">u8"感谢大家对涛哥系列文章的支持，也"</span></span><br><span class="line">                  <span class="string">"欢迎直接联系我寻求帮助"</span> &lt;&lt; logCommands[<span class="number">0</span>];</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>顺便说一下，设置了console的工程不能显示出彩色，得把console去掉。<br><img src="/images/ConsoleColor/3.jpg" alt="a03d569415d1c9ab1aaa6fb1a1d62d3a.png"></p>

    </div>
    
    <div class="reward" ontouchstart>
    <div class="reward-wrap">赏
        <div class="reward-box">
            
            <span class="reward-type">
                <img class="alipay" src="/img/zhifubao.jpg"><b>支付宝打赏</b>
            </span>
            
            
            <span class="reward-type">
                <img class="wechat" src="/img/weixin.jpg"><b>微信打赏</b>
            </span>
            
        </div>
    </div>
    <p class="reward-tip">
        为众人抱薪者,不可使其冻毙于霜雪
    </p>
</div>
    
    <div class="post-footer">
        <div>
            
            转载声明：
            文章采用<a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议</a>进行许可, 转载请注明出处 © <a href="https://jaredtao.github.io" target="_blank">武威的涛哥</a>
            
            
        </div>
        <div>
            
        </div>
    </div>
</article>
<div class="article-nav prev-next-wrap clearfix">
    
    <a href="/2019/04/30/%E7%8E%A9%E8%BD%ACQt(2)-%E8%87%AA%E5%88%B6%E7%AE%80%E6%98%93%E5%A5%BD%E7%9C%8B%E7%9A%84%E6%97%A5%E5%BF%97%E7%B3%BB%E7%BB%9F/" class="pre-post btn btn-default" title='玩转Qt(2)-自制简易好看的日志系统'>
        <i class="fa fa-angle-left fa-fw"></i><span class="hidden-lg">上一篇</span>
        <span class="hidden-xs">
            玩转Qt(2)-自制简易好看的日志系统</span>
    </a>
    
    
    <a href="/2019/04/29/%E6%B6%9B%E5%93%A5%E5%8D%9A%E5%AE%A2%E6%9D%82%E8%B0%88/" class="next-post btn btn-default" title='涛哥博客杂谈'>
        <span class="hidden-lg">下一篇</span>
        <span class="hidden-xs">
            涛哥博客杂谈</span><i class="fa fa-angle-right fa-fw"></i>
    </a>
    
</div>

<div id="comments">
    

<div id="vcomments" class="valine"></div>

<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="/assets/valine.min.js"></script>

<script>
new Valine({
    av: AV,
    el: '#vcomments',
    appId: 'qegD4552u6FU9HoNDvRsonko-gzGzoHsz',
    appKey: 'eitB2FV5n2qyMHcDM7x6EQpt',
    placeholder: '说点什么吧',
    notify: false,
    verify: true,
    avatar: 'mm',
    meta: 'nick,mail'.split(','),
    pageSize: '10',
    path: window.location.pathname,
    lang: 'zh-CN'.toLowerCase()
})
</script>


</div>


                </main>
                
                    <aside id="article-toc" role="navigation" class="col-md-4">
    <div class="widget">
        <h3 class="title">
            文章目录
        </h3>
        
        <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#简介"><span class="toc-text">简介</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#原理"><span class="toc-text">原理</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#代码"><span class="toc-text">代码</span></a></li></ol>
        
    </div>
</aside>
                
            </div>
        </div>
    </section>
    <footer class="main-footer">
    <div class="container">
        <div class="row">
        </div>
    </div>
</footer>
<a id="back-to-top" class="icon-btn hide">
    <i class="fa fa-chevron-up"></i>
</a>
    <div class="copyright">
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <div class="busuanzi">
    
    访问量:
    <strong id="busuanzi_value_site_pv">
        <i class="fa fa-spinner fa-spin"></i>
    </strong>
    &nbsp; | &nbsp;
    访客数:
    <strong id="busuanzi_value_site_uv">
        <i class="fa fa-spinner fa-spin"></i>
    </strong>
    
</div>
            </div>
            <div class="col-sm-12">
                <span>Copyright &copy;
                    2019
                    
                </span> |
                <span>
                    Powered by <a href="//hexo.io" class="copyright-links" target="_blank" rel="nofollow">Hexo</a>
                </span> |
                <span>
                    Theme by <a href="//github.com/shenliyang/hexo-theme-snippet.git" class="copyright-links" target="_blank" rel="nofollow">Snippet</a>
                </span>
            </div>
        </div>
    </div>
</div>



<script src="/assets/tagcanvas.min.js?rev=2.9.js"></script>

<script>
var tagOption = {
    textColour: '#444', // 字体颜色
    outlineMethod: 'block', // 选中模式
    outlineColour: '#FFDAB9', // 选中模式的颜色
    interval: 30 || 30, // 动画帧之间的时间间隔，值越大，转动幅度越大
    textHeight: 13,
    outlineRadius: 3,
    freezeActive: true || '', // 选中的标签是否继续滚动
    frontSelect: true || '', // 不选标签云后部的标签
    initial: [0.1, -0.1],
    depth: 0.5,
    decel: 0.95,
    maxSpeed: 0.03,
    reverse: true || '', // 是否反向触发
    fadeIn: 500, // 进入动画时间
    wheelZoom: false || '' // 是否启用鼠标滚轮
}
TagCanvas.Start('tag-cloud-3d', '', tagOption);
</script>


<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>


<script src="/js/app.js?rev=@@hash.js"></script>

</body>
</html>